package com.sjp.controller.admin;

import com.sjp.pojo.BlogCategory;
import com.sjp.service.CategoryService;
import com.sjp.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/admin")
public class EditController {

    @Autowired
    private CategoryService categoryService;

    @RequestMapping("/edit")
    public String edit(Model model){
        //这里如果需要优化，就建一个CategoryDto 只用存分类名称和id即可
        List<BlogCategory> categories = categoryService.queryAllCategory();
        model.addAttribute("categories",categories);
        return "admin/edit";
    }

    @RequestMapping("/edit/save")
    @ResponseBody
    public Result save(){
        return null;
    }

}
